package com.springbootbase.springbootproject.controller;

import com.alibaba.fastjson.JSON;
import com.springbootbase.springbootproject.pojo.Evaluation;
import com.springbootbase.springbootproject.pojo.MentorData;
import com.springbootbase.springbootproject.pojo.Result;
import com.springbootbase.springbootproject.service.SupervisorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/supervisor")
public class SupervisorController {
    @Autowired
    private SupervisorService supervisorService;


    /** 获得 level 层次大学
     * @param level 大学层次
     * @return
     */
    @PostMapping("/GetUniversity")
    public Result<List> GetUniversity(String level){
        List u = supervisorService.getUniversityByLevel(level);
        return Result.success(u);
    }

    /** 查询大学对应的学院
     * @param university 大学
     * @return
     */
    @PostMapping("/GetDepartment")
    public Result<List> GetDepartment(String university){
        List u = supervisorService.getDepartmentByUniversity(university);
        return  Result.success(u);
    }

    /** 查询大学，学院里的导师
     * @param university 大学
     * @param department 学院
     * @return
     */
    @PostMapping("/GetSupervisor")
    public Result<List> GetSupervisor(String university,String department){
        List<String> u = supervisorService.getSupervisorByDepartment(university,department);
        return  Result.success(u);
    }

    @PostMapping("/GetReview")
    public Result<List> GetReview(String university,String department,String supervisor){
        ArrayList<Evaluation> u = supervisorService.getReview(university,department,supervisor);
        MentorData mentorData = supervisorService.getReview3(university,department,supervisor);
        List s = new ArrayList<>();
        s.add(u);
        s.add(mentorData);
        return  Result.success(s);
    }
    @PostMapping("/requestReview")
    public Result requestReview(String university,String department,String supervisor){
        Map e = supervisorService.getReview2(university,department,supervisor);
        return  Result.success(e);
    }

    @GetMapping("/getHindex")
    public Result getHindex(String id){
        String res = supervisorService.getHindex(id);
        return Result.success(res);
    }

    @GetMapping("/getId")
    public Result getId(String name){
        String res = supervisorService.getId(name);
        return Result.success(res);
    }


}